/*******************************************************************************
 * Copyright (c) 2007 University of Oslo.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     University of Oslo - initial API and implementation
 *******************************************************************************/

package com.cea.papyrus.diagram.sequence.sedi.edit.manager;

import org.eclipse.gef.GraphicalEditPart;
import org.eclipse.gef.tools.CellEditorLocator;
import org.eclipse.uml2.uml.InteractionUse;

import com.cea.papyrus.diagram.sequence.sedi.edit.IOEditPart;

/**
 * Special DirectEditManager for InteractionUses because they edit the
 * name of the referred to interaction, not their own name.
 * 
 * @author frankd@ifi.uio.no
 */
public class InteractionUseEditManager extends LabelDirectEditManager {

	public InteractionUseEditManager(GraphicalEditPart source, CellEditorLocator locator) {
		super(source, locator);
	}

	@SuppressWarnings("unchecked")
	protected String getInitialEditorText() {
		String initialValue = null;
		
		IOEditPart iuseEP = (IOEditPart) getEditPart();
		InteractionUse iuse = (InteractionUse) iuseEP.getUmlElement();
		if (iuse.getRefersTo() != null)
			initialValue = iuse.getRefersTo().getName();
		
		return (initialValue != null) ? initialValue : "";
	}	
}
